package com.leyou.upload.cotroller;

import com.leyou.upload.service.IUpLoadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.Map;

@RestController
public class UpLoadController {

    @Autowired
    private IUpLoadService uploadService;

    @GetMapping("signature")
    public ResponseEntity<Map<String, Object>> getAliSignature() {
        return ResponseEntity.ok(uploadService.getAliSignature());
    }

    /**
     * 上传图片
     * @param file
     * @return
     */
    @PostMapping("image")
    public ResponseEntity<String> upLoad(@RequestParam("file") MultipartFile file) {
        return ResponseEntity.status(HttpStatus.OK).body(uploadService.upLoad(file));
    }
}
